Constrained Placement help

I am trying to do a simple constrained placement...how would one modify the below simple example to get the label inside the frame?

 

DB dbBox=create("Test Window")
DBE dbeMyFrame=frame(dbBox,"Test Frame",500,100)
DBE dbeLabel=label(dbBox,"Hello world.")
dbeLabel->"right"->"unattached"
dbeLabel->"left"->"inside"->dbeMyFrame
show dbBox

 


strathglass - Tue May 30 07:46:54 EDT 2017

Re: Constrained Placement help
PekkaMakinen - Tue May 30 08:05:52 EDT 2017

DB dbBox=create("Test Window")
DBE dbeMyFrame=frame(dbBox,"Test Frame",500,100)
DBE dbeLabel=label(dbBox,"Hello world.")
dbeLabel->"top"->"inside"->dbeMyFrame
dbeLabel->"left"->"inside"->dbeMyFrame
dbeLabel->"right"->"inside"->dbeMyFrame
show dbBox

 

Re: Constrained Placement help
strathglass - Tue May 30 08:32:45 EDT 2017

OK, thanks...that worked!

But to ensure I know how to extend this, I tried to add two frames, one below the other, and each with two elements (a label and a field).

It mostly works, but what I would like to fix or understand is:

  1. Why the extra space below the first field in the first frame?
  2. The left alignment of the second field with the second label in the second frame is obviously not working, how to fix this?
DB dbBox=create("Test Window")
//One frame with two elements (label and field):
DBE dbeMyFrame=frame(dbBox,"Test Frame")
DBE dbeLabel=label(dbBox,"Hello world.")
DBE dbeField=field(dbBox,"Your short input? ","",10)
//Another frame with another two elements:
DBE dbeMyFrame2=frame(dbBox,"Another Test Frame")
DBE dbeLabel2=label(dbBox,"More elements in this frame...")
DBE dbeField2=field(dbBox,"Your long input? ","",25)
//Place the two elements inside first frame:
dbeLabel->"top"->"inside"->dbeMyFrame
dbeLabel->"left"->"inside"->dbeMyFrame
dbeLabel->"right"->"inside"->dbeMyFrame
dbeField->"top"->"spaced"->dbeLabel
dbeField->"left"->"aligned"->dbeLabel
//Place frame 2 spaced below frame 1:
dbeMyFrame2->"top"->"spaced"->dbeMyFrame
//And place the two elements inside frame 2:
dbeLabel2->"top"->"inside"->dbeMyFrame2
dbeLabel2->"left"->"inside"->dbeMyFrame2
dbeLabel2->"right"->"inside"->dbeMyFrame2
dbeField2->"top"->"spaced"->dbeLabel2
dbeField2->"left"->"aligned"->dbeLabel2
show dbBox

Re: Constrained Placement help
strathglass - Tue May 30 08:49:56 EDT 2017

I noticed that if I specifiy the size of the first frame I can resolve issue 1, e.g.:

DBE dbeMyFrame=frame(dbBox,"Test Frame",200,70)

But I would like not to have to do that, ...can't I have the frame size automatically to hold the contents without the extra space?

 

I also notice I can resolve issue 2 (get field2 in frame2 left aligned) if I change the last placement line: instead of left aligning field2 with label2, this works:

dbeField2->"left"->"inside"->dbeMyFrame2

 

Wouldn't it be lovely if the exact behaviour of all these constrained placement features were actually documented?

 

Re: Constrained Placement help
strathglass - Tue May 30 09:26:23 EDT 2017

So in my real world program things are not working as expected.

Can anyone share the general rules to place a sequence of DBEs (labels, fields, checkboxes) one below the other in a frame, with a sequence of several such frames (also one below the other)?

Also, is it possible to place an element below the last frame? Not sure how you would control left/right placement in such a case (I tried top->spaced from last frame, and left->aligned with last frame...didn't work).

Re: Constrained Placement help
PekkaMakinen - Wed May 31 00:42:21 EDT 2017

strathglass - Tue May 30 09:26:23 EDT 2017

So in my real world program things are not working as expected.

Can anyone share the general rules to place a sequence of DBEs (labels, fields, checkboxes) one below the other in a frame, with a sequence of several such frames (also one below the other)?

Also, is it possible to place an element below the last frame? Not sure how you would control left/right placement in such a case (I tried top->spaced from last frame, and left->aligned with last frame...didn't work).

I am always fighting with constrained placement when I use it. Sometimes I succeed and after that try not to change anything. But for help this thread has some hints: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014872846&ps=25

Re: Constrained Placement help
pommCannelle - Wed May 31 05:14:24 EDT 2017

(

The funny thing is that ... if you use the 'true' placement, there is no problem. 
You may try to use 

dbeField2->"left"->"inside"->dbeMyFrame2

instead of 

dbeField2->"left"->"aligned"->dbeLabel2

Have fun !

)

Re: Constrained Placement help
strathglass - Wed May 31 08:05:03 EDT 2017

Pekka, pC - helpful info, thanks! I have it working passibly now.   :)